using System;

namespace SharpMud.MudLib.SAMPLE.Commands.Metadata
{
	[AttributeUsage(System.AttributeTargets.Class)]
	public class AliasAttribute : System.Attribute
	{
		private SharpMud.Text.Matching.StringMatcher[] _CommandMatchers;
		
		#region Constructors
		protected AliasAttribute()
		{
		}

		public AliasAttribute(SharpMud.Text.Matching.StringMatchingType aliasMatchingType, string aliasPattern)
			:this(new SharpMud.Text.Matching.StringMatcher(aliasMatchingType,aliasPattern))
		{
		}
		public AliasAttribute(string exactAlias)
			:this(new SharpMud.Text.Matching.StringMatcher(SharpMud.Text.Matching.StringMatchingType.Exact,exactAlias))
		{
		}
		public AliasAttribute(params string[] exactAliases)
		{
			Init(exactAliases);
		}
		public AliasAttribute(SharpMud.Text.Matching.StringMatcher commandMatcher)
		{
			Init(commandMatcher);
		}
		public AliasAttribute(SharpMud.Text.Matching.StringMatcher[] commandMatchers)
		{
			Init(commandMatchers);
		}

		private void Init(SharpMud.Text.Matching.StringMatcher[] commandMatchers)
		{
			this._CommandMatchers = commandMatchers;
		}
		private void Init(SharpMud.Text.Matching.StringMatcher commandMatcher)
		{
			Init(new SharpMud.Text.Matching.StringMatcher[] {commandMatcher});
		}
		private void Init(string exactAlias)
		{
			Init(new string[] {exactAlias});
		}
		private void Init(string[] exactAliases)
		{
			SharpMud.Text.Matching.StringMatcher[] cm = new SharpMud.Text.Matching.StringMatcher[exactAliases.Length];
			for(int x = 0;x<exactAliases.Length;x++)
			{
				cm[x] = SharpMud.Text.Matching.StringMatcher.MakeExactMatcher(exactAliases[x]);
			}
			Init(cm);
		}
		#endregion

		public SharpMud.Text.Matching.StringMatcher[] CommandMatchers
		{
			get
			{
				return _CommandMatchers;
			}
		}
	}
}
